home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / HPACK78S.ZIP / tags.h < prev    next >
C/C++ Source or Header  |  1992-11-23  |  17KB  |  505 lines

  1. /****************************************************************************
  2. *                                                                            *
  3. *                            HPACK Multi-System Archiver                        *
  4. *                            ===========================                        *
  5. *                                                                            *
  6. *                            HPACK Archive Tag Settings                        *
  7. *                             TAGS.H  Updated 22/08/92                        *
  8. *                                                                            *
  9. * This program is protected by copyright and as such any use or copying of    *
  10. *  this code for your own purposes directly or indirectly is highly uncool    *
  11. *                      and if you do so there will be....trubble.                *
  12. *                 And remember: We know where your kids go to school.            *
  13. *                                                                            *
  14. *        Copyright 1990 - 1992  Peter C.Gutmann.  All rights reserved        *
  15. *                                                                            *
  16. ****************************************************************************/
  17.  
  18. /* This file defines all tags values used in HPACK.  The format for tags
  19.    is described in HPACKSTD.TXT */
  20.  
  21. #ifdef __MAC__
  22.   #include "hpackio.h"
  23. #else
  24.   #include "io/hpackio.h"
  25. #endif /* __MAC__ */
  26.  
  27. /*                         --------- WARNING --------
  28.  
  29.                 This file should be treated as READ-ONLY!
  30.    Never make any changes to this file yourself as it will probably render
  31.    your version of HPACK incompatible with all other versions.  Changes to
  32.    this  file  should  be  submitted to  Peter  Gutmann  so  they  can  be
  33.    redistributed to all HPACK developers.
  34.  
  35.                         --------------------------- */
  36.  
  37. /* The number of short tags.  ID's of 0 .. NO_SHORT_TAGS are short tag ID,
  38.    ID's over NO_SHORT_TAGS are long ID's.  The maximum short-tag ID has a
  39.    special status in that is denotes a long tag (a variable-length structure
  40.    rather than the fixed-format 16-bit short tag) */
  41.  
  42. #define NO_SHORT_TAGS        1024
  43. #define isShortTag(tagID)    ( ( tagID ) < NO_SHORT_TAGS )
  44.  
  45. /* The magic value for the tagID which denotes a long tag */
  46.  
  47. #define LONG_BASE        0xFFC0
  48.  
  49. /* The basic size of each tag (long tags are actially variable-length,
  50.    the value given here is the size of the tag header field */
  51.  
  52. #define SHORT_TAGSIZE            sizeof( WORD )
  53. #define LONG_TAGSIZE            ( sizeof( WORD ) + sizeof( BYTE ) )
  54.  
  55. /* Macros to handle short tags */
  56.  
  57. #define TAGID_MASK        0xFFC0        /* Mask to extract tag ID's */
  58. #define DATALEN_MASK    0x003F        /* Mask to extract short tag lengths */
  59. #define TAGID_SHIFT        6
  60. #define SHORT_TAGLEN    ( 1 << TAGID_SHIFT )    /* Max.data size for short tag */
  61.  
  62. /* Macros to handle long tags */
  63.  
  64. #define LONGTAG_BYTE_WORD    0x0000    /* Length = BYTE, uncoprLength = WORD */
  65. #define LONGTAG_WORD_WORD    0x0010    /* Length = WORD, uncoprLength = WORD */
  66. #define LONGTAG_WORD_LONG    0x0020    /* Length = WORD, uncoprLength = LONG */
  67. #define LONGTAG_LONG_LONG    0x0030    /* Length = LONG, uncoprLength = LONG */
  68.  
  69. #define LONGTAG_FORMAT_MASK    0x000E    /* Mask for long tag storage type */
  70. #define LONGTAG_LENGTH_MASK    0x0030    /* Mask for long tag length field */
  71. #define LONGTAG_FORMAT_SHIFT    1    /* Shift amount for format field */
  72.  
  73. /* A dummy length for tags.  If the tag is stored uncompressed, we don't
  74.    really need to store the compressed and uncompressed length, so if
  75.    writeTag() finds this value it just ignores it */
  76.  
  77. #define LEN_NONE        0L
  78.  
  79. /* An illegal tag ID used to indicate tags which we can't handle */
  80.  
  81. #define BAD_TAGID        0xFFFF
  82.  
  83. /* Classes of tags */
  84.  
  85. enum { TAGCLASS_NONE, TAGCLASS_ATTRIBUTE, TAGCLASS_COMMENT, TAGCLASS_TIME,
  86.        TAGCLASS_ICON, TAGCLASS_MISC };
  87.  
  88. /* Storage formats for long tags */
  89.  
  90. enum { TAGFORMAT_STORED, TAGFORMAT_PACKED };
  91.  
  92. /* The struct containing information on each tag */
  93.  
  94. typedef struct {
  95.                LONG dataLength;        /* Size of tagged data */
  96.                LONG uncoprLength;    /* Size of uncompressed tagged data */
  97.                WORD tagID;            /* The tag's ID */
  98.                BYTE dataFormat;        /* Storage format type */
  99.                } TAGINFO;
  100.  
  101. /* Prototypes for the read/write tag functions */
  102.  
  103. int writeTag( WORD tagID, const WORD store, const LONG dataLength, const LONG uncoprLength );
  104. int writeDirTag( WORD tagID, const WORD store, const LONG dataLength, const LONG uncoprLength );
  105. int readTag( long *tagFieldSize, TAGINFO *tagInfo );
  106.  
  107. ATTR readAttributeData( const WORD attributeID );
  108.  
  109. /****************************************************************************
  110. *                                                                            *
  111. *                                    Tag ID's                                *
  112. *                                                                            *
  113. ****************************************************************************/
  114.  
  115. /* Tag ID's are specified as an enumerated type to solve potential problems
  116.    with duplication of tag ID's.  New types *must* be added to the end of
  117.    the list, *never* to the middle.  The first group is the short tag ID's,
  118.    the second the long tag ID's.  In some cases long tag ID's can have short
  119.    forms, which are the same as the long forms but with an internal '_S_'.
  120.    These are never seen by the rest of HPACK, and are only used by read/
  121.    writeTag() */
  122.  
  123. enum { TAG_MSDOS_ATTR, TAG_UNIX_ATTR, TAG_MAC_ATTR, TAG_QNX_ATTR,
  124.        TAG_ARC_ATTR, TAG_AMIGA_ATTR, TAG_ATARI_ATTR, TAG_APPLE_ATTR,
  125.        TAG_OS2_ATTR, TAG_VMS_ATTR, TAG_ACCESS_TIME, TAG_BACKUP_TIME,
  126.        TAG_CREATION_TIME, TAG_EXPIRATION_TIME, TAG_S_ERROR, TAG_S_COMMENT,
  127.        TAG_S_LONGNAME, TAG_POSITION, TAG_WINSIZE, TAG_VERSION_NUMBER,
  128.        TAG_MAC_TYPE, TAG_MAC_CREATOR, TAG_LOAD_ADDRESS, TAG_EXECUTE_ADDRESS };
  129.  
  130. enum { TAG_COMMENT = NO_SHORT_TAGS, TAG_OS2_ICON, TAG_LONGNAME, TAG_ERROR,
  131.        TAG_OS2_MISC_EA, TAG_SECURITY_INFO, TAG_RESOURCE_FORK, TAG_AMIGA_ICON };
  132.  
  133. /****************************************************************************
  134. *                                                                           *
  135. *                                Attribute Tags                                *
  136. *                                                                            *
  137. ****************************************************************************/
  138.  
  139. /* TAG_AMIGA_ATTR: Amiga file info, organised as follows:
  140.  
  141.    BYTE : attributes
  142.  
  143.    7 6 5 4 3 2 1 0
  144.    H S P A R W X D
  145.    | | | | | | | +-> Delete flag
  146.    | | | | | | +---> Execute bit
  147.    | | | | | +-----> Write bit
  148.    | | | | +-------> Read bit
  149.    | | | +---------> Archive bit (clear = file changed)
  150.    | | +-----------> Pure flag (program is reentrant)
  151.    | +-------------> Script file flag
  152.    +---------------> Hidden flag */
  153.  
  154. #define AMIGA_ATTR_DELETE    0x01
  155. #define AMIGA_ATTR_EXECUTE    0x02
  156. #define AMIGA_ATTR_WRITE    0x04
  157. #define AMIGA_ATTR_READ        0x08
  158. #define AMIGA_ATTR_ARCHIVE    0x10
  159. #define AMIGA_ATTR_PURE        0x20
  160. #define AMIGA_ATTR_SCRIPT    0x40
  161. #define AMIGA_ATTR_HIDDEN    0x80
  162.  
  163. #define LEN_AMIGA_ATTR        1
  164.  
  165. /* TAG_APPLE_ATTR: Apple IIgs file info, organised as follows:
  166.  
  167.    WORD : attributes
  168.  
  169.    FEDCBA98 7 6 5 432 1 0
  170.    ----+--- | | | -+- | +-> Read permission
  171.        |    | | |  |  +---> Write permission
  172.        |    | | |  +------> Unused - set to 0
  173.        |    | | +---------> Backup needed
  174.        |    | +-----------> Rename
  175.        |    +-------------> Destroy
  176.        +------------------> Unused - set to 0 */
  177.  
  178. #define APPLE_ATTR_READ        0x0001
  179. #define APPLE_ATTR_WRITE    0x0002
  180. #define APPLE_ATTR_BACKUP    0x0020
  181. #define APPLE_ATTR_RENAME    0x0040
  182. #define APPLE_ATTR_DESTROY    0x0080
  183.  
  184. #define LEN_APPLE_ATTR        2
  185.  
  186. /* TAG_ARC_ATTR: Archimedes file info, organised as follows:
  187.  
  188.    BYTE : attributes
  189.  
  190.    76 54 3 2 10
  191.    xx rw L x RW
  192.    -+ -+ | | ++-> Read/Write Access - Owner
  193.     |  | | +----> Unused - set to 0
  194.     |  | +------> Locked bit
  195.     |  +--------> Read/Write Access - Others
  196.     +-----------> Unused - set to 0 */
  197.  
  198. #define    ARC_ATTR_WRITE_OWNER    0x0001
  199. #define ARC_ATTR_READ_OWNER        0x0002
  200. #define ARC_ATTR_LOCKED            0x0008
  201. #define ARC_ATTR_WRITE_OTHER    0x0010
  202. #define ARC_ATTR_READ_OTHER        0x0020
  203.  
  204. #define LEN_ARC_ATTR            1
  205.  
  206. /* TAG_ATARI_ATTR: Atari ST file info, organised as follows:
  207.  
  208.    BYTE : attributes
  209.  
  210.    76 5 4 3 2 1 0
  211.    xx A D V S H R
  212.    +- | | | | | +-> Read-only flag
  213.    |  | | | | +---> Hidden/Invisible flag
  214.    |  | | | +-----> System flag
  215.    |  | | +-------> Volume label flag (not used in HPACK - set to 0)
  216.    |  | +---------> Directory flag (not used in HPACK - set to 0)
  217.    |  +-----------> Archive bit
  218.    +--------------> Unused - set to 0 */
  219.  
  220. #define ATARI_ATTR_RDONLY    0x01
  221. #define ATARI_ATTR_HIDDEN    0x02
  222. #define ATARI_ATTR_SYSTEM    0x04
  223. #define ATARI_ATTR_ARCHIVE    0x20
  224.  
  225. #define LEN_ATARI_ATTR        1
  226.  
  227. /* TAG_MAC_ATTR: Macintosh file info, organised as follows:
  228.  
  229.    WORD : attributes
  230.  
  231.    F E D C B A 9 8 76543210
  232.    | | | | | | | | ++++++++-> Unused - set to 0
  233.    | | | | | | | +----------> Init
  234.    | | | | | | +------------> Changed
  235.    | | | | | +--------------> Busy
  236.    | | | | +----------------> Bozo
  237.    | | | +------------------> System
  238.    | | +--------------------> Bundle
  239.    | +----------------------> Invisible
  240.    +------------------------> Locked */
  241.  
  242. #define MAC_ATTR_INIT        0x0100
  243. #define MAC_ATTR_CHANGED    0x0200
  244. #define MAC_ATTR_BUSY        0x0400
  245. #define MAC_ATTR_BOZO        0x0800
  246. #define MAC_ATTR_SYSTEM        0x1000
  247. #define MAC_ATTR_BUNDLE        0x2000
  248. #define MAC_ATTR_INVISIBLE    0x4000
  249. #define MAC_ATTR_LOCKED        0x8000
  250.  
  251. #define LEN_MAC_ATTR        2
  252.  
  253. /* TAG_MSDOS_ATTR: The MSDOS attribute bits, organised as follows:
  254.  
  255.    BYTE : attributes
  256.  
  257.    7 6 5 4 3 2 1 0
  258.    N x A D V S H R
  259.    | | | | | | | +-> Read-only flag
  260.    | | | | | | +---> Hidden/Invisible flag
  261.    | | | | | +-----> System flag
  262.    | | | | +-------> Volume label flag (not used in HPACK - set to 0)
  263.    | | | +---------> Directory flag (not used in HPACK - set to 0)
  264.    | | +-----------> Archive bit
  265.    | +-------------> Unused - set to 0
  266.    +---------------> Nominally unused - used by Novell netware? */
  267.  
  268. #define MSDOS_ATTR_RDONLY    0x01
  269. #define MSDOS_ATTR_HIDDEN    0x02
  270. #define MSDOS_ATTR_SYSTEM    0x04
  271. #define MSDOS_ATTR_ARCHIVE    0x20
  272.  
  273. #define LEN_MSDOS_ATTR        1
  274.  
  275. /* TAG_OS2_ATTR: The OS/2 attribute bits, organised as follows:
  276.  
  277.    BYTE : attributes
  278.  
  279.    7 6 5 4 3 2 1 0
  280.    N x A D V S H R
  281.    | | | | | | | +-> Read-only flag
  282.    | | | | | | +---> Hidden/Invisible flag
  283.    | | | | | +-----> System flag
  284.    | | | | +-------> Volume label flag (not used in HPACK - set to 0)
  285.    | | | +---------> Directory flag (not used in HPACK - set to 0)
  286.    | | +-----------> Archive bit
  287.    | +-------------> Unused - set to 0
  288.    +---------------> Nominally unused - used by Novell netware? */
  289.  
  290. #define OS2_ATTR_RDONLY        0x01
  291. #define OS2_ATTR_HIDDEN        0x02
  292. #define OS2_ATTR_SYSTEM        0x04
  293. #define OS2_ATTR_ARCHIVE    0x20
  294.  
  295. #define LEN_OS2_ATTR        1
  296.  
  297. /* TAG_QNX_ATTR: QNX 2.x/3.x file info, organised as follows:
  298.  
  299.    BYTE : group permission
  300.    BYTE : member permission
  301.    BYTE : owner permission
  302.    BYTE : owner group
  303.    BYTE : owner member */
  304.  
  305. #define LEN_QNX_ATTR            5
  306.  
  307. /* TAG_UNIX_ATTR: The UNIX permission flag bits, organised as follows:
  308.  
  309.    WORD : attributes
  310.  
  311.    FEDC B A 9 876 543 210
  312.    ???? u g s rwx rwx rwx
  313.    --+- | | | -+- -+- +++-> Other rwx bits
  314.      |  | | |  |   +------> Group rwx bits
  315.      |  | | |  +----------> Owner rwx bits
  316.      |  | | +-------------> Sticky bit
  317.      |  | +---------------> SGID flag
  318.      |  +-----------------> SUID flag
  319.      +--------------------> ? (not used in HPACK - set to 0) */
  320.  
  321. #define UNIX_ATTR_OTHER_X    0x0001
  322. #define UNIX_ATTR_OTHER_W    0x0002
  323. #define UNIX_ATTR_OTHER_R    0x0004
  324. #define UNIX_ATTR_GROUP_X    0x0008
  325. #define UNIX_ATTR_GROUP_W    0x0010
  326. #define UNIX_ATTR_GROUP_R    0x0020
  327. #define UNIX_ATTR_OWNER_X    0x0040
  328. #define UNIX_ATTR_OWNER_W    0x0080
  329. #define UNIX_ATTR_OWNER_R    0x0100
  330. #define UNIX_ATTR_STICKY    0x0200
  331. #define UNIX_ATTR_SGID        0x0400
  332. #define UNIX_ATTR_SUID        0x0800
  333.  
  334. #define UNIX_ATTR_RBITS        ( UNIX_ATTR_OTHER_R | UNIX_ATTR_GROUP_R | UNIX_ATTR_OWNER_R )
  335. #define UNIX_ATTR_WBITS        ( UNIX_ATTR_OTHER_W | UNIX_ATTR_GROUP_W | UNIX_ATTR_OWNER_W )
  336. #define UNIX_ATTR_XBITS        ( UNIX_ATTR_OTHER_X | UNIX_ATTR_GROUP_X | UNIX_ATTR_OWNER_X )
  337.  
  338. #define LEN_UNIX_ATTR        2
  339.  
  340. /* TAG_VMS_ATTR: The VMS permission flag bits, organised as follows:
  341.  
  342.    WORD : attributes
  343.  
  344.    FEDC BA98 7654 3210
  345.    RWED RWED RWED RWED
  346.    --+- --+- --+- --+--> World RWED bits
  347.      |    |    +-------> Group RWED bits
  348.      |    +------------> Owner RWED bits
  349.      +-----------------> System RWED bits */
  350.  
  351. #define VMS_ATTR_WORLD_R    0x0001
  352. #define VMS_ATTR_WORLD_W    0x0002
  353. #define VMS_ATTR_WORLD_E    0x0004
  354. #define VMS_ATTR_WORLD_D    0x0008
  355. #define VMS_ATTR_GROUP_R    0x0010
  356. #define VMS_ATTR_GROUP_W    0x0020
  357. #define VMS_ATTR_GROUP_E    0x0040
  358. #define VMS_ATTR_GROUP_D    0x0080
  359. #define VMS_ATTR_OWNER_R    0x0100
  360. #define VMS_ATTR_OWNER_W    0x0200
  361. #define VMS_ATTR_OWNER_E    0x0400
  362. #define VMS_ATTR_OWNER_D    0x0800
  363. #define VMS_ATTR_SYSTEM_R    0x1000
  364. #define VMS_ATTR_SYSTEM_W    0x2000
  365. #define VMS_ATTR_SYSTEM_E    0x4000
  366. #define VMS_ATTR_SYSTEM_D    0x8000
  367.  
  368. #define VMS_ATTR_RBITS        ( VMS_ATTR_WORLD_R | VMS_ATTR_GROUP_R | VMS_ATTR_OWNER_R | VMS_ATTR_SYSTEM_R )
  369. #define VMS_ATTR_WBITS        ( VMS_ATTR_WORLD_W | VMS_ATTR_GROUP_W | VMS_ATTR_OWNER_W | VMS_ATTR_SYSTEM_W )
  370. #define VMS_ATTR_EBITS        ( VMS_ATTR_WORLD_E | VMS_ATTR_GROUP_E | VMS_ATTR_OWNER_E | VMS_ATTR_SYSTEM_E )
  371. #define VMS_ATTR_DBITS        ( VMS_ATTR_WORLD_D | VMS_ATTR_GROUP_D | VMS_ATTR_OWNER_D | VMS_ATTR_SYSTEM_D )
  372.  
  373. #define LEN_VMS_ATTR        2
  374.  
  375. /****************************************************************************
  376. *                                                                            *
  377. *                                    Time Tags                                *
  378. *                                                                            *
  379. ****************************************************************************/
  380.  
  381. /* TAG_ACCESS_TIME, TAG_BACKUP_TIME, TAG_CREATION_TIME, TAG_EXPIRATION_TIME:
  382.    Various timestamps for those systems which store multiple dates for each
  383.    file/directory (the modification date is stored in the file header),
  384.    organised as follows:
  385.  
  386.    LONG : access time
  387.    LONG : backup time
  388.    LONG : creation time
  389.    LONG : expiration time */
  390.  
  391. #define LEN_ACCESS_TIME        4
  392. #define LEN_BACKUP_TIME        4
  393. #define LEN_CREATION_TIME    4
  394. #define LEN_EXPIRATION_TIME    4
  395.  
  396. /****************************************************************************
  397. *                                                                           *
  398. *                            System-specific Crufties                        *
  399. *                                                                            *
  400. ****************************************************************************/
  401.  
  402. /* TAG_AMIGA_ICON, TAG_OS2_ICON: Tags for icons.  Amiga and OS/2 icons are
  403.    stored as long tags since they are usually quite large.  Amiga icons are
  404.    stored as follows:
  405.  
  406.    WORD : pixel offset from left of display element
  407.    WORD : pixel offset from top of display element
  408.    WORD : pixel width
  409.    WORD : pixel height
  410.    WORD : number of bitplanes
  411.    BYTE : mask for which bitplanes to use
  412.    BYTE : mask to define what to do with unused bitplanes
  413.    BYTE : Workbench object type (useful only on Amiga)
  414.    WORD[] : icon data, row-first, in bitplane blocks, bits stored flush left.
  415.             Number of words = ( ( width + 15 ) / 16 ) * height * depth
  416.    WORD : crc16
  417.  
  418.    OS/2 icons are stored in some obscure format whose precise definition is
  419.    stored encrypted with triple Lucifer, fifteen feet underground in a
  420.    lead-lined vault in Armonk with a backup copy in East Fishkill */
  421.  
  422. /* TAG_LONGNAME: Tags for longer filenames if a shorter version is also
  423.    present (used under the OS/2 HPFS when files must be truncated to 8.3 for
  424.    DOS compatibility), organised as follows:
  425.  
  426.    BYTE[] : ASCIZ filename
  427.  
  428.    This tag has a short and long form */
  429.  
  430. /* TAG_POSITION, TAG_WINSIZE: Tags for window sizes and positions within a
  431.    window, organized as follows:
  432.  
  433.    WORD : X position in window
  434.    WORD : Y position in window
  435.  
  436.    WORD : window top coordinate
  437.    WORD : window left coordinate
  438.    WORD : window bottom coordinate
  439.    WORD : window right coordinate */
  440.  
  441. #define LEN_POSITION        4
  442. #define LEN_WINSIZE            8
  443.  
  444. /* TAG_VERSION_NUMBER: Version number tag, organised as follows:
  445.  
  446.    WORD : version number */
  447.  
  448. #define LEN_VERSION_NUMBER    2
  449.  
  450. /* TAG_MAC_TYPE, TAG_MAC_CREATOR: Mac file type and creator, organised as
  451.    follows:
  452.  
  453.    LONG : type
  454.  
  455.    LONG : creator */
  456.  
  457. #define LEN_MAC_TYPE        4
  458. #define LEN_MAC_CREATOR        4
  459.  
  460. /* TAG_RESOURCE_FORK: Mac resource fork, organised as follows:
  461.  
  462.    BYTE[] : resource fork data */
  463.  
  464. /* TAG_LOAD_ADDRESS, TAG_EXECUTE_ADDRESS: Load and execute address, used by
  465.    the Archimedes for compatibility with some 6502 software.  Organised as
  466.    follows:
  467.  
  468.    LONG : load address
  469.  
  470.    LONG : execute address */
  471.  
  472. #define LEN_LOAD_ADDRESS    4
  473. #define LEN_EXECUTE_ADDRESS    4
  474.  
  475. /****************************************************************************
  476. *                                                                           *
  477. *                        Security and Data Validation                        *
  478. *                                                                            *
  479. ****************************************************************************/
  480.  
  481. /* TAG_ERROR_ID: The error recovery info, organised as follows:
  482.  
  483.    LONG : error ID
  484.    BYTE[] : file header
  485.    BYTE[] : ASCIZ fileName
  486.    WORD : crc16 */
  487.  
  488. #define ERROR_ID        "\xFE\xFE\xFE\xFE"    /* Reasonably uncommon pattern */
  489. #define ERROR_ID_SIZE    ( sizeof( ERROR_ID ) - 1 )    /* -1 for '\0' */
  490.  
  491. /* TAG_SECURITY_INFO: Authentication information for a file, stored as an
  492.    encrypted data packet - see HPACKSTD.TXT */
  493.  
  494. /****************************************************************************
  495. *                                                                           *
  496. *                                Miscellaneous                                *
  497. *                                                                            *
  498. ****************************************************************************/
  499.  
  500. /* TAG_COMMENT: Comments of 0-63 and 64-4,294,967,296 ASCII chars, organised
  501.    as follows:
  502.  
  503.    BYTE[] : ASCIZ comment
  504.    WORD : crc16 */
  505.